#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef char fchar_t;
typedef uint32_t faddr_t;

#define FILE_NORMAL 0
#define FILE_DIR    1

struct iramfs_node_t
{
	 char name[16];
	 uint8_t type;
	 /* directory level, for parsing */
	 uint32_t level;
	 faddr_t size;
};

int main(int argc, const char **argv)
{
	 int level;
	 char buf[17];
	 level = 0;
	 fgets(buf, 17, stdin);
	 int count;
	 sscanf(buf, "%d", &count);
	 fwrite(&count, 1, sizeof(count), stdout);
	 while (!feof(stdin))
	 {
		  fgets(buf, 17, stdin);
		  int i;
		  for (i = 0; i != 120; ++i)
		  {
			   if (buf[i] == '\r' || buf[i] == '\n')
			   {
					buf[i] = '\0';
					break;
			   }
		  }
		  switch (buf[0])
		  {
		  case '{':
			   ++ level;
			   break;
		  case '}':
			   -- level;
			   break;
		  case '+':
		  {
			   struct iramfs_node_t node;
			   memcpy(&node.name[0], &buf[1], 16);
			   node.type = FILE_DIR;
			   node.level = level;
			   node.size = 0;
			   fwrite(&node, 1, sizeof(node), stdout);
			   break;
		  }
		  case '.':
		  {
			   FILE *f;
			   char fbuf[120];
			   fgets(fbuf, 120, stdin);
			   int i;
			   for (i = 0; i != 120; ++i)
			   {
					if (fbuf[i] == '\r' || fbuf[i] == '\n')
					{
						 fbuf[i] = '\0';
						 break;
					}
			   }
			   f = fopen(fbuf, "rb+");
			   fseek(f, 0, SEEK_END);

			   struct iramfs_node_t node;
			   memcpy(&node.name[0], &buf[1], 16);
			   node.type = FILE_NORMAL;
			   node.level = level;
			   node.size = ftell(f);
			   fwrite(&node, 1, sizeof(node), stdout);
			   fseek(f, 0, SEEK_SET);

			   while (!feof(f))
			   {
					char cbuf[4096];
					size_t w = fread(cbuf, 1, 4096, f);
					fwrite(cbuf, 1, w, stdout);
			   }			   
			   fclose(f);

		  }
		  }
	 }
	 return 0;
}
